package com.ali.framework.common.entity.order;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.*;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @Author: Smile
 * @Date: 2023/12/07/17:17
 * @Description:
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("trade_order_info")
@TableComment("交易中心，订单主表")
public class TradeOrderInfoDO {

    private static final long serialVersionUID = 1L;

    @Column(comment = "会员的openid", length = 50, defaultValue = "")
    @IsNotNull
    @Index
    private String openId;

    @Column(comment = "会员id", defaultValue = "0")
    @IsNotNull
    @Index
    private Long memberId;

    @Column(comment = "下单的设备id", defaultValue = "0")
    @IsNotNull
    @Index
    private Long robotId;

    @Column(comment = "设备名称", defaultValue = "", length = 50)
    private String robotName;

    @Column(comment = "设备编号", defaultValue = "", length = 20)
    private String robotCode;

    @Column(comment = "设备详细地址", defaultValue = "")
    private String robotAddress;

    @Column(comment = "区域id", defaultValue = "0")
    @IsNotNull
    private Long regionId;

    @Column(comment = "订单编号", length = 40, defaultValue = "")
    @IsNotNull
    @Unique
    private String orderNo;

    @Column(comment = "订单状态，1：待付款，2：已取消，3：已完成，4：售后中（退货申请待审核），" +
            "5：交易关闭（退货审核不通过），6：交易关闭（完成退款），7：待取串，8：待发货，9：已发货，10：烤制中 11:交易失败",
            type = MySqlTypeConstant.TINYINT, defaultValue = "0")
    @IsNotNull
    private Integer orderStatus;

    @Column(comment = "订单子状态，1：待付款，2：已取消，301：取串完成，302：退款完成，303：已签收，304：交易关闭（退货审核不通过），" +
            "4: 售后中 ，7：待取串，8：待发货，9：已发货，10：烤制中，" +
            "110：支付超时，111：支付失败，112：烤制失败", defaultValue = "0")
    @IsNotNull
    private Integer orderSubStatus;

    @Column(comment = "交易状态描述", length = 50, defaultValue = "")
    @IsNotNull
    private String tradeStatusDesc;

    @Column(comment = "支付方式，1：微信，2：支付宝",
            type = MySqlTypeConstant.TINYINT, defaultValue = "0")
    @IsNotNull
    private Integer payType;

    @Column(comment = "订单类型，1：设备订单（native）；2：线上小程序订单（online）,3：商城订单，4：代理商商城订单",
            type = MySqlTypeConstant.TINYINT, defaultValue = "0")
    @IsNotNull
    private Integer orderType;

    @Column(comment = "订单来源", type = MySqlTypeConstant.TINYINT, defaultValue = "0")
    @IsNotNull
    private Integer orderSource;

    @Column(comment = "口味：0：麻辣；1：孜盐", type = MySqlTypeConstant.TINYINT, defaultValue = "0")
    @IsNotNull
    private Integer skuTaste;

    @Column(comment = "订单购买总数量", defaultValue = "0")
    @IsNotNull
    private Integer totalQuantity;

    @Column(comment = "订单购买总金额", defaultValue = "0.00", length = 8, decimalLength = 2)
    @IsNotNull
    private BigDecimal totalAmount;

    @Column(comment = "促销活动折扣金额，预留字段", defaultValue = "0.00", length = 8, decimalLength = 2)
    @IsNotNull
    private BigDecimal discountAmount;

    @Column(comment = "促销优惠券Id，与优惠券金额关联", defaultValue = "0")
    @IsNotNull
    private Long couponAchieveId;

    @Column(comment = "优惠券抵扣金额", defaultValue = "0.00", length = 8, decimalLength = 2)
    @IsNotNull
    private BigDecimal couponAmount;

    @Column(comment = "应付金额，订单总金额 - 促销活动折扣金额 - 优惠券抵扣金额", defaultValue = "0.00", length = 8, decimalLength = 2)
    @IsNotNull
    private BigDecimal payableAmount;

    @Column(comment = "订单备注", defaultValue = "")
    @IsNotNull
    private String orderComment;

    @TableField("member_addrId")
    @Column(comment = "用户地址id", defaultValue = "0")
    @IsNotNull
    private Long memberAddrId;

    @TableField("gmt_payable_expire")
    @Column(comment = "支付截至时间", defaultValue = "0")
    @IsNotNull
    private Long payExpire;

    @Column(comment = "商户的dept id", defaultValue = "0")
    @IsNotNull
    @Index
    private Long deptMerchantId;

    @Column(comment = "代理商的dept id", defaultValue = "0")
    @IsNotNull
    @Index
    private Long deptAgentId;

    @Column(comment = "分公司的dept id", defaultValue = "0")
    @IsNotNull
    private Long deptBranchId;

    @Column(comment = "取串码",defaultValue = "",length = 8)
    @IsNotNull
    private String takeCode;

    @Column(comment = "是否取串的标识 0：未取；1：已取",type = MySqlTypeConstant.TINYINT,
            defaultValue = "0")
    @IsNotNull
    private Boolean takeSign;

    @Column(type = MySqlTypeConstant.DATE, comment = "下单日期")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    protected LocalDate orderDate;

    @Column(type = MySqlTypeConstant.DATETIME, comment = "支付时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime payAmountTime;


    @TableField(fill = FieldFill.INSERT)
    @Column(type = MySqlTypeConstant.DATETIME, comment = "开始烤制时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected LocalDateTime gmtRoastStart;



    @Column(comment = "抓取坐标点",defaultValue = "",length = 10)
    @IsNotNull
    private String grabSign;

    @Column(comment = "烤制火候",defaultValue = "0")
    @IsNotNull
    private Integer bakingHeat;



}
